package polymorphic;

class Shape{
    public void draw(){
    }
}
class Circle extends Shape{
    @Override
    public void draw(){
        System.out.println("○");
    }
}
class Triangle extends Shape{
    @Override
    public void draw(){
        System.out.println("△");
    }
}
class Rectangle extends Shape{
    @Override
    public void draw(){
        System.out.println("□");
    }
}
public class TestDemo3 {
    public static void drawShapes(){
        Circle circle=new Circle();
        Triangle triangle=new Triangle();
        Rectangle rectangle=new Rectangle();
        Shape[] shapes={circle,triangle,circle,triangle,rectangle};
        for(int i=0;i<shapes.length;i++){
            shapes[i].draw();
        }
    }
    public static void main(String[] args) {
        drawShapes();
    }
    public static void drawMap(Shape shape){
        shape.draw();
    }
    public static void main2(String[] args) {
        drawMap(new Circle());
        drawMap(new Triangle());
        drawMap(new Rectangle());

    }
    public static void main1(String[] args) {
        Shape shape=new Circle();
        shape.draw();
        Shape shape2=new Triangle();
        shape2.draw();
        Shape shape3=new Rectangle();
        shape3.draw();
    }
}
